<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet" />
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}" />
    <link rel="stylesheet" th:href="@{/erp/Widget/zTree/css/zTreeStyle/zTreeStyle.css}" type="text/css">
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}" />
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet" />
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}" />
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}" />
    <link th:href="@{/erp/Widget/icheck/icheck.css}" rel="stylesheet" type="text/css" />
</head>
<body>

<div class="type_style">
    <div class="type_title">部门信息</div>
    <div class="type_content">
        <span id="spans1" style="display:block">
		<div class="Operate_btn">  <a href="javascript:;" onClick="xinzeng()" class="btn  btn-warning"><i class="icon-plus align-top bigger-125"></i>新增下级部门</a> <a th:href="@{/dept/deptDelete(id=${depts.id})}" id="shanchu" class="btn  btn-danger"><i class="icon-trash   align-top bigger-125"></i>删除该部门</a> </div>

			<form action="/dept/deptHighUpdate" method="post" class="form form-horizontal" id="form-user-add" onsubmit="return checkInputs()">
				  <ul class=" page-content">
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>部门编号：</label>
			  <div class="formControls " style="width:280px;">
				 <input type="text" class="input-text" th:value="${depts.id}" readonly="readonly" name="id" id="updId">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>部门名称：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" th:value="${depts.deptName}" id="deptNames"  name="deptName">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>部门经理：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" th:value="${depts.deptManger}" id="deptMangers" name="deptManger">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>联系电话：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" th:value="${depts.deptTel}" id="deptTels"  name="deptTel">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red"></span>固定电话：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" th:value="${depts.deptPhone}" id="deptPhones" name="deptPhone">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red"></span>邮箱：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" th:value="${depts.deptEmail}" id="deptEmails"  name="deptEmail">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label">部门简介：</label>
			  <div class="formControls">
				<textarea name="deptRemark" rows="" th:text="${depts.deptRemark}" class="textarea"   datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" >这个部门很好</textarea>

			  </div>
			</div>
		  </ul>
		<div class="">
            <div class="" style=" text-align:center">
              <input class="btn btn-primary radius" type="submit" value="保存">
			  <a href="/human/depatmentPage"><input class="btn btn-primary radius" type="button" value="取消"></a>
            </div>
          </div>
        </form></span>


        <span id="spans2" style="display:none;">

		<form action="/dept/deptLowAdd" method="post" onsubmit="return checkInput()">
				<ul class=" page-content">
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>部门编号：</label>
			  <div class="formControls " style="width:280px;">
				 <input type="text" class="input-text" id="idss"  name="id" onblur="isDeptId()" readonly="readonly">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>部门名称：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" value="" id="deptName"   name="deptName" onblur="isDeptName()">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>部门经理：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" value="" id="deptManger"  name="deptManger">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>联系电话：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" value="" id="deptTel" onblur="isTel()"  name="deptTel">
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>固定电话：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" value="" id="deptPhone" onblur="isPhone()"  name="deptPhone"><br>
				  <span style="color: red;">格式为区号+电话号码。000-0000000</span>
			  </div>
			</div>
			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>邮箱：</label>
			  <div class="formControls ">
				<input type="text" class="input-text" value="" id="deptEmail" onblur="isEmail()" name="deptEmail">
			  </div>
			</div>

			<div class="Operate_cont clearfix">
			  <label class="form-label"><span class="c-red">*</span>部门简介：</label>
			  <div class="formControls">
				<textarea name="deptRemark" rows="" class="textarea"  placeholder="说点什么...最少输入10个字符" datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" ></textarea>

			  </div>
			</div>
			<div class="">
            <div class="" style=" text-align:center">
              <input class="btn btn-primary radius" id="tijiao" type="submit" value="提交">
			  <a href="/dept/deptManger"><input class="btn btn-primary radius" id="tijiao1" type="button" value="取消"></a>
            </div>
          </div>
		  </ul>
            </form>
        </span>
    </div>
</div>
</body>
<script>

	function isDeptName() {
		var deptName = $("#deptName").val();
		$.ajax({
			type:"get",
			url:"/dept/isDeptName",
			data:{"deptName":deptName},
			success:function (res) {
				if (res.rs) {

				} else {
					layer.msg("部门名称已存在", {icon: 2});
				}
			}
		})
	}

	function isDeptId() {
		var deptId = $("#id").val();
		$.ajax({
			type:"get",
			url:"/dept/isDeptId",
			data:{"deptId":deptId},
			success:function (res) {
				if (res.rs) {

				} else {
					layer.msg("部门编号已存在", {icon: 2});
				}
			}
		})
	}
	function isTel(){
		var s =$("#deptTel").val();
		if(!(/^1[3456789]\d{9}$/.test(s))){
            parent.layer.msg("联系电话有误，请重填", {icon: 2});
			return false;
		}
	}
	function isPhone(){
		var s =$("#deptPhone").val();
		if(!/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,8}$/.test(s)){
            parent.layer.msg("固定电话有误", {icon: 2});
			return false;
		}
	}


	function checkInput() {
		var s =$("#deptEmail").val();
		var flag  = false;
		var deptId = $("#idss").val();
		if(deptId == ""){
			parent.layer.msg("部门编号不能为空", {icon: 2});
			return false;
		}else if($("#deptName").val() == ""){
			parent.layer.msg("部门名称不能为空", {icon: 2});
			return false;
		}else if($("#deptManger").val() == ""){
			parent.layer.msg("部门经理不能为空", {icon: 2});
			return false;
		}else if($("#deptTel").val() == ""){
			parent.layer.msg("联系电话不能为空", {icon: 2});
			return false;
		}else if($("#deptPhone").val() == ""){
			parent.layer.msg("固定电话不能为空", {icon: 2});
			return false;
		}else if($("#deptEmail").val() == ""){
			parent.layer.msg("邮箱不能为空", {icon: 2});

			if(!/^[a-zA-Z0-9_-]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/.test(s)){
				parent.layer.msg("邮箱有误，请重填", {icon: 2});
				return false;
			}
			return false;
		}else if($("#postName").val() == ""){
			parent.layer.msg("部门职位不能为空", {icon: 2});
			return false;
		}else{
			var deptTel =$("#deptTel").val();
			var deptPhone =$("#deptPhone").val();
			if(!/^[a-zA-Z0-9_-]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/.test(s)){
				parent.layer.msg("邮箱有误，请重填", {icon: 2});
				return false;
			}else if(!(/^1[3456789]\d{9}$/.test(deptTel))){
				parent.layer.msg("联系电话有误，请重填", {icon: 2});
				return false;
			}else if(!/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,8}$/.test(deptPhone)){
				parent.layer.msg("固定电话有误，请重填", {icon: 2});
				return false;
			} else{
				flag = true;
			}
		}
		return flag;
	}



	function checkInputs() {
		var s =$("#deptEmails").val();
		var flag  = false;
	 if($("#deptNames").val() == ""){
			parent.layer.msg("部门名称不能为空", {icon: 2});
			return false;
		}else if($("#deptMangers").val() == ""){
			parent.layer.msg("部门经理不能为空", {icon: 2});
			return false;
		}else if($("#deptTels").val() == ""){
			parent.layer.msg("联系电话不能为空", {icon: 2});
			return false;
		}else if($("#deptPhones").val() == ""){
			parent.layer.msg("固定电话不能为空", {icon: 2});
			return false;
		}else if($("#deptEmails").val() == ""){
			parent.layer.msg("邮箱不能为空", {icon: 2});

			if(!/^[a-zA-Z0-9_-]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/.test(s)){
				parent.layer.msg("邮箱有误，请重填", {icon: 2});
				return false;
			}
			return false;
		}else if($("#postName").val() == ""){
			parent.layer.msg("部门职位不能为空", {icon: 2});
			return false;
		}else{
			var deptTel =$("#deptTels").val();
			var deptPhone =$("#deptPhones").val();
			if(!/^[a-zA-Z0-9_-]+@([a-zA-Z0-9]+\.)+(com|cn|net|org)$/.test(s)){
				parent.layer.msg("邮箱有误，请重填", {icon: 2});
				return false;
			}else if(!(/^1[3456789]\d{9}$/.test(deptTel))){
				parent.layer.msg("联系电话有误，请重填", {icon: 2});
				return false;
			}else if(!/^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{7,8}$/.test(deptPhone)){
				parent.layer.msg("固定电话有误，请重填", {icon: 2});
				return false;
			} else{
				flag = true;
			}
		}
		return flag;
	}
</script>
</html>